home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / sbf3.zip / ENVIRON.C < prev    next >
C/C++ Source or Header  |  1993-09-19  |  1KB  |  53 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include "sb.h"
  6.  
  7. int Sb_Get_Params(void)
  8. {
  9.     char *t, *blaster;
  10.  
  11.     /* Set arguments to reasonable values (Soundblaster defaults) */
  12.     SbIOaddr = 0x220;
  13.     SbIRQ = 7;
  14.     SbDMAchan = 1;
  15.  
  16.     /* Attempt to read environment variable */
  17.     t = getenv("BLASTER");
  18.  
  19.     /* Is the environment variable set? */
  20.     if(t == NULL)
  21.     return 1;
  22.  
  23.     /* Duplicate the string so that we don't trash our environment */
  24.     blaster = strdup(t);
  25.  
  26.     /* Now parse the BLASTER variable */
  27.     t = strtok(blaster," \t");
  28.     while(t)
  29.     {
  30.     switch(toupper(t[0]))
  31.     {
  32.         case 'A':                               /* I/O address */
  33.         SbIOaddr = (int)strtol(t+1,NULL,16);
  34.         break;
  35.         case 'I':                               /* Hardware IRQ */
  36.         SbIRQ = atoi(t+1);
  37.         break;
  38.         case 'D':                               /* DMA channel */
  39.         SbDMAchan = atoi(t+1);
  40.         break;
  41.         case 'T':                               /* Soundblaster type */
  42.         SbType = atoi(t+1);
  43.         break;
  44.         default:
  45.         printf("Unknown BLASTER option %c\n",t[0]);
  46.         break;
  47.     }
  48.     t = strtok(NULL," \t");
  49.     }
  50.     free(blaster);
  51.     return 0;
  52. }
  53.